/**
 * Host.js
 *
 * @description :: A model definition represents a database table/collection.
 * @docs        :: https://sailsjs.com/docs/concepts/models-and-orm/models
 */

module.exports = {

  attributes: {

    //  ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦  ╦╔═╗╔═╗
    //  ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
    //  ╩  ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
    fleetApid: {
      example: 54622,
      type: 'number',
      unique: true,
      required: true
    },

    displayName: {
      example: 'Eric\'s MacBook Pro 16',
      type: 'string',
    },

    teamDisplayName: {
      example: 'Workstations',
      description: 'The name of the team that this host is on, or "No team" if this host does not belong to a team.',
      type: 'string',
      required: true,
    },

    teamApid: {
      example: 2,
      description: 'The the Fleet API ID of the host\'s team or 0 if the host has no team',
      type: 'number',
      defaultsTo: 0
    },

    hardwareSerialNumber: {
      description: 'The harware serial number of this host',
      extendedDescription: 'This is the hardware_serial value from the response from the get hosts endpoint of the Fleet API. If a host does not have a hardware_serial number (e.g., a ChromeOS host), this value will be set to N/A',
      type: 'string',
      required: true,
    },

    uuid: {
      description: 'The uuid of this host in the Fleet instance',
      type: 'string',
      required: true,
    },

    //  ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
    //  ║╣ ║║║╠╩╗║╣  ║║╚═╗
    //  ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝


    //  ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
    //  ╠═╣╚═╗╚═╗║ ║║  ║╠═╣ ║ ║║ ║║║║╚═╗
    //  ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
    operatingSystem: { model: 'OperatingSystem', required: true },
    vulnerabilities: { collection: 'Vulnerability', through: 'VulnerabilityInstall', via: 'host' },
  },

};

